package com.example.mvpdemo2.mvpBase;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public abstract class BaseActivity<P extends BasePresenter, CONTRACT> extends AppCompatActivity  implements View.OnClickListener {

    public P mPresenter;

    public abstract CONTRACT getContract();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getContextViewID());

        initView();
        initListener();
        initData();

        mPresenter = getmPresenterInstance();
        mPresenter.bindView(this);
    }

    public abstract void initView();
    public abstract void initListener();
    public abstract void initData();
    public abstract int getContextViewID();
    public abstract P getmPresenterInstance();

    @Override
    protected void onDestroy() {
        super.onDestroy();
        destroy();
        mPresenter.unbindView();
    }

    public abstract void destroy();


}
